package com.java.example.ui.viewmodel

import android.app.Application
import android.content.Context
import androidx.lifecycle.AndroidViewModel
import com.blankj.utilcode.util.SPUtils
import com.java.example.app.AccountManager
import com.java.example.databinding.FragmentPersonCenterBinding
import com.java.example.ui.dialog.SettingDialog

class PersonCenterVewModel(application: Application) : AndroidViewModel(application) {
    lateinit var binding: FragmentPersonCenterBinding
    private var settingDialog: SettingDialog? = null

    fun showSetting(context: Context) {
        settingDialog?.showDialog(context, ::logout) ?: run {
            settingDialog = SettingDialog.create()
            settingDialog!!.showDialog(context, ::logout)
        }
//        FullScreenDialog(context).show()
    }

    private fun logout(context: Context) {
        SPUtils.getInstance().put("isAgency", false)
        AccountManager.logout()
    }
}